package cc.comac.mom.datahandlers.entity;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cc.comac.mom.dao.entity.QualityQarVerifyDao;
import cc.comac.mom.entity.QualityQarVerifyEntity;
import cc.comac.mom.util.BaseEntityDataUtil;
import cc.comac.mom.util.ResultBean;

@Component
public class QualityQarVerifyDataHandler extends ServiceImpl<QualityQarVerifyDao, QualityQarVerifyEntity>{

	@Autowired
	private QualityQarVerifyDao qualityQarVerifyDao;
	
	@Autowired
	private BaseEntityDataUtil baseEntityDataUtil;
	
	public ResultBean insertBatch(List<QualityQarVerifyEntity> list) {
		ResultBean resultBean = new ResultBean(true);
		if(list == null || list.size()<1) {
			resultBean.setErrorMessge("数据为空");
			return resultBean;
		}
		for(QualityQarVerifyEntity item :list) {
			baseEntityDataUtil.setBaseEntityData(item);
		}
		boolean saveBatch = this.saveBatch(list);
		if(!saveBatch) {
			resultBean.setErrorMessge("保存验证信息失败");
			return resultBean;
		}
		return resultBean;
	}

	
	public ResultBean updateQarVerifyData (QualityQarVerifyEntity qualityQarVerifyEntity) {
		ResultBean resultBean = new ResultBean(true);
		baseEntityDataUtil.updateBaseEntityData(qualityQarVerifyEntity);
		qualityQarVerifyDao.updateById(qualityQarVerifyEntity);
		return resultBean;
	}

}
